﻿using UnityEngine;
using System.Collections;

public class FX_scale_loop : MonoBehaviour {

	public bool loop = false;
	public Vector3 vScaleValue = new Vector3 (1, 1, 1);
	
	public float duration = 1.0f;
	
	
	float timer = 0;
	
	[SerializeField]
	AnimationCurve curveX;
	[SerializeField]
	AnimationCurve curveY;
	[SerializeField]
	AnimationCurve curveZ;
	
	void Update ()
	{
		
		Vector3 localScale = transform.localScale;
		localScale.x = curveX.Evaluate(timer)* vScaleValue.x;
		localScale.y = curveY.Evaluate(timer)* vScaleValue.y;
		localScale.z = curveZ.Evaluate(timer)* vScaleValue.z;
		transform.localScale = localScale;
		
		timer += Time.deltaTime/duration;

		if (loop) {
			if(timer >= 1.0f){
				timer = 0f;
			}
		}
	}
}
